import pytest
import csv
import os

BASE_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


def read_data_from_csv(file_path):
    item = []
    c = csv.reader(open(file_path, "r", encoding='utf-8'))
    for i in c:
        item.append(i)
    print(f"返回的参数：{item}")
    return item

# item是一个列表嵌套列表的结构
# pytest会将item里面的每个子列表依此传进去
# item = [
#     ['suyu', '123'],
#     ['zuoyu', '456']
# ]

@pytest.mark.parametrize("params",read_data_from_csv(BASE_PATH+"\\pytest17_parametrize参数化数据来自csv文件\\data.csv"))
def test_case(params):
    print(params)
    print(f"uname={params[0]},pwd={params[1]}")
